package com.shujia.flink.source

import org.apache.flink.streaming.api.scala._

object Demo1Source {
  def main(args: Array[String]): Unit = {
    //创建环境
    val env: StreamExecutionEnvironment = StreamExecutionEnvironment.getExecutionEnvironment

    /**
     * 基于本地集合构建DataStream   ---- 有界流
     *
     */

    val ds: DataStream[Int] = env.fromCollection(List(1, 2, 3, 4, 5, 6, 7, 8, 9))

    ds.print()


    /**
     * 基于文件source  --- 有界流
     *
     */
    val studentDS: DataStream[String] = env.readTextFile("data/students.txt")

    studentDS.print()

    /**
     * 读取socket   --- 无界流
     *
     */

    val linesDS: DataStream[String] = env.socketTextStream("master", 8888)
    linesDS.print()

    /**
     * 自定义斯诺克
     * kafka
     *
     */


    env.execute()


  }

}
